#ifndef __dial_strategy_h__
#define __dial_strategy_h__ 1
#include "sys.h"
#include "thread_pool.h"
#include "cJSON.h"
#include "ping_tactics.h"
#include "tcp_tactics.h"
#include "dns_tactics.h"
#include "http_tactics.h"
#include "traceroute_tactics.h"
#include "httpspeed_tactics.h"
#include "udpspeed_tactics.h"

enum{
    DIAL_TASK_FLAG_RUN= 0,
    DIAL_TASK_FLAG_STOP,
    DIAL_TASK_FLAG_CANCEL,
};

typedef struct Dial_Tactics_s{
    ping_tactics_t ping;
    tcp_tactics_t tcp;
    dns_tactics_t dns;
    http_tactics_t http;
    traceroute_tactics_t traceroute;
    httpspeed_tactics_t httpspeed;
    udpspeed_tactics_t udpspeed;
}Dial_Tactics_t;

typedef struct Dial_Task_s{
    char id[64];
    char version[64];
    char nodeUrl[256];
    char probeId[64];
    time_t startTime, endTime;
    int cycleTime, collectTime;
    char kafka_url[512];
    Dial_Tactics_t tactics;
    int flag;
    TAILQ_ENTRY(Dial_Task_s) entry;
}Dial_Task_t;
TAILQ_HEAD(Dial_Task_Head, Dial_Task_s);

struct Dial_Task{
    struct Dial_Task_Head head;
    int count;
    thread_pool_t *tpool;
};

int dial_tactics_parse(Dial_Tactics_t* tactics, cJSON* json);
void* dial_task_run(void *arg);
void dial_task_free_all(struct Dial_Task* taskall);
void dial_task_free(struct Dial_Task_s* task);
void dial_task_all_set_flag(struct Dial_Task* taskall, int flag);
void dial_task_set_flag(Dial_Task_t* task, int flag);
#endif